<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Swagger UI</title>
    <link rel="icon" type="image/png" href="images/favicon-32x32.png" sizes="32x32"/>
    <link rel="icon" type="image/png" href="images/favicon-16x16.png" sizes="16x16"/>
    <link href='css/typography.css' media='screen' rel='stylesheet' type='text/css'/>
    <link href='css/reset.css' media='screen' rel='stylesheet' type='text/css'/>
    <link href='css/screen.css' media='screen' rel='stylesheet' type='text/css'/>
    <link href='css/reset.css' media='print' rel='stylesheet' type='text/css'/>
    <link href='css/print.css' media='print' rel='stylesheet' type='text/css'/>
    <script src='lib/jquery-1.8.0.min.js' type='text/javascript'></script>
    <script src='lib/jquery.slideto.min.js' type='text/javascript'></script>
    <script src='lib/jquery.wiggle.min.js' type='text/javascript'></script>
    <script src='lib/jquery.ba-bbq.min.js' type='text/javascript'></script>
    <script src='lib/handlebars-2.0.0.js' type='text/javascript'></script>
    <script src='lib/underscore-min.js' type='text/javascript'></script>
    <script src='lib/backbone-min.js' type='text/javascript'></script>
    <script src='swagger-ui.js' type='text/javascript'></script>
    <script src='lib/highlight.7.3.pack.js' type='text/javascript'></script>
    <script src='lib/marked.js' type='text/javascript'></script>
    <script src='lib/swagger-oauth.js' type='text/javascript'></script>

    <script type="text/javascript">
        var url = window.location.pathname;
        var temp = url.split("swagger");
        var baseUrl = temp[0];

        if (baseUrl.endsWith("/")) {
            baseUrl = baseUrl.substring(0, baseUrl.length - 1);
        }

        function log(msg) {
            if (console) {
                console.log(msg)
            }
        }

        $(function () {
            $.ajax({
                url: baseUrl + "/api-docs",
                method: 'get',
                dataType: 'json',
                success: function (data) {
                    var apis = data.apis;
                    var select = $('#input_baseUrl')[0];
                    select.options.length = 0;

                    for (var i in apis) {
                        var api = apis[i];

                        var desc = api.description;
                        var url = "/api-docs" + api.path;

                        select.options.add(new Option(desc, baseUrl + url));
                    }

                    var _url = baseUrl + "/api-docs" + apis[0].path;

                    window.swaggerUi = new SwaggerUi({
                        url: _url,
                        dom_id: "swagger-ui-container",
                        supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
                        onComplete: function (swaggerApi, swaggerUi) {
                            $('a.toggleEndpointList').remove();
                            $('a.collapseResource').remove();
                            $('a.expandResource').remove();
                            $('div.footer').remove();
                            $('pre code').each(function (i, e) {
                                hljs.highlightBlock(e)
                            });
                            window.Docs.toggleEndpointListForResource("fix_this");
                        },
                        onFailure: function (data) {
                            log("Unable to Load SwaggerUI");
                        },
                        docExpansion: "none"
                    });

                    window.swaggerUi.load();
                }
            });

            $('#input_baseUrl').bind("change", function () {
                window.swaggerUi = new SwaggerUi({
                    url: $("#input_baseUrl").val(),
                    dom_id: "swagger-ui-container",
                    supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
                    onComplete: function (swaggerApi, swaggerUi) {
                        $('a.toggleEndpointList').remove();
                        $('a.collapseResource').remove();
                        $('a.expandResource').remove();
                        $('div.footer').remove();
                        $('pre code').each(function (i, e) {
                            hljs.highlightBlock(e)
                        });
                        window.Docs.toggleEndpointListForResource("fix_this");
                    },
                    onFailure: function (data) {
                        log("Unable to Load SwaggerUI");
                    },
                    docExpansion: "none"
                });

                window.swaggerUi.load();
            });
        });
    </script>
</head>

<body class="swagger-section">
<div id='header'>
    <div class="swagger-ui-wrap">
        <a id="logo" href="http://swagger.io">swagger</a>

        <form id='api_selector' style="margin-right: 35%">
            <div class='input'><select id="input_baseUrl" style="height: 25px;width:420px"></select></div>
        </form>
    </div>
</div>

<div id="message-bar" class="swagger-ui-wrap" data-sw-translate>&nbsp;</div>
<div id="swagger-ui-container" class="swagger-ui-wrap" data-sw-translate></div>
</body>
</html>
